{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true,
    "pycharm": {
     "is_executing": false
    }
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "import datetime\n",
    "import requests\n",
    "import time\n",
    "import random\n",
    "import sys\n",
    "sys.path.insert(0, '..')\n",
    "import d2l"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "outputs": [
    {
     "name": "stdout",
     "text": [
      "id                       int64\nlatitude               float64\nlongitude              float64\ndate_time               object\ncruise                  object\nseawifs_filename        object\nseawifs_es_error         int64\nseawifs_pixel_total      int64\nseawifs_tdiff            int64\nseawifs_solz           float64\nseawifs_senz           float64\nseawifs_cv             float64\nseawifs_windspeed      float64\nseawifs_chlor_a        float64\ninsitu_chlor_a_type     object\ninsitu_chlor_a         float64\nseawifs_rrs412         float64\nseawifs_rrs443         float64\nseawifs_rrs490         float64\nseawifs_rrs510         float64\nseawifs_rrs555         float64\nseawifs_rrs670         float64\ncount                   object\ndtype: object\n"
     ],
     "output_type": "stream"
    }
   ],
   "source": [
    "chlDataFile = r\"F:\\05Ocean\\CHL\\SEABASS\\1598671119556259_chlor_a_seawifs_fixed.csv\"\n",
    "datatypes={\"seawifs_chlor_a\":np.float,\"insitu_chlor_a\":np.float,\"depth_water\":np.float}\n",
    "dt = pd.read_csv(chlDataFile,skiprows=(0),header=(0),parse_dates=True,dtype=datatypes)\n",
    "dt['count'] = None # 新增一列\n",
    "searchedCnt = 1\n",
    "totalCnt = dt.shape[0]\n",
    "print (dt.dtypes)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "outputs": [
    {
     "data": {
      "text/plain": "       id  latitude  longitude         date_time        cruise  \\\n0  280136   29.0527   -87.3232   2010/5/13 21:02  2010_05_wbii   \n1  211974   17.6968   -66.0012  2003/10/28 18:12           a22   \n2    1265   45.3139    12.5083   2003/3/18 11:23     aaot_2003   \n3    1268   45.3139    12.5083   2003/5/13 10:15     aaot_2003   \n4    1276   45.3139    12.5083   2003/6/20 11:59     aaot_2003   \n\n                                    seawifs_filename  seawifs_es_error  \\\n0  S2010133195617.L2_MLAC.R0000020308_2010_05_wbi...                 0   \n1  S2003301161018.L2_MLAC.R0000020313_17N_17N_66W...                 0   \n2  S2003077110425.L2_MLAC.R0000020314_45N_45N_12E...                 0   \n3  S2003133112858.L2_MLAC.R0000020314_45N_45N_12E...                 0   \n4  S2003171110723.L2_MLAC.R0000020314_45N_45N_12E...                 0   \n\n   seawifs_pixel_total  seawifs_tdiff  seawifs_solz  ...  seawifs_chlor_a  \\\n0                   25          -2866         35.43  ...         0.191785   \n1                   25          -6455         31.10  ...         0.087906   \n2                   25           -507         46.33  ...         1.974525   \n3                   25           5341         28.09  ...         1.779388   \n4                   25          -2101         22.03  ...         1.121444   \n\n   insitu_chlor_a_type  insitu_chlor_a  seawifs_rrs412 seawifs_rrs443  \\\n0                  chl         0.17375        0.004684       0.004580   \n1                  chl         0.06900        0.010744       0.008795   \n2                chl_a         2.09430        0.004212       0.004806   \n3                chl_a         0.96620        0.004451       0.004953   \n4                chl_a         0.71310        0.003378       0.003701   \n\n   seawifs_rrs490  seawifs_rrs510  seawifs_rrs555  seawifs_rrs670  count  \n0        0.003976        0.002848        0.001410       -0.000022   None  \n1        0.006032        0.003241        0.001549        0.000112   None  \n2        0.006625        0.006604        0.006209        0.000984   None  \n3        0.005663        0.005642        0.005284        0.000921   None  \n4        0.004466        0.004142        0.003531        0.000316   None  \n\n[5 rows x 23 columns]",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>id</th>\n      <th>latitude</th>\n      <th>longitude</th>\n      <th>date_time</th>\n      <th>cruise</th>\n      <th>seawifs_filename</th>\n      <th>seawifs_es_error</th>\n      <th>seawifs_pixel_total</th>\n      <th>seawifs_tdiff</th>\n      <th>seawifs_solz</th>\n      <th>...</th>\n      <th>seawifs_chlor_a</th>\n      <th>insitu_chlor_a_type</th>\n      <th>insitu_chlor_a</th>\n      <th>seawifs_rrs412</th>\n      <th>seawifs_rrs443</th>\n      <th>seawifs_rrs490</th>\n      <th>seawifs_rrs510</th>\n      <th>seawifs_rrs555</th>\n      <th>seawifs_rrs670</th>\n      <th>count</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>280136</td>\n      <td>29.0527</td>\n      <td>-87.3232</td>\n      <td>2010/5/13 21:02</td>\n      <td>2010_05_wbii</td>\n      <td>S2010133195617.L2_MLAC.R0000020308_2010_05_wbi...</td>\n      <td>0</td>\n      <td>25</td>\n      <td>-2866</td>\n      <td>35.43</td>\n      <td>...</td>\n      <td>0.191785</td>\n      <td>chl</td>\n      <td>0.17375</td>\n      <td>0.004684</td>\n      <td>0.004580</td>\n      <td>0.003976</td>\n      <td>0.002848</td>\n      <td>0.001410</td>\n      <td>-0.000022</td>\n      <td>None</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>211974</td>\n      <td>17.6968</td>\n      <td>-66.0012</td>\n      <td>2003/10/28 18:12</td>\n      <td>a22</td>\n      <td>S2003301161018.L2_MLAC.R0000020313_17N_17N_66W...</td>\n      <td>0</td>\n      <td>25</td>\n      <td>-6455</td>\n      <td>31.10</td>\n      <td>...</td>\n      <td>0.087906</td>\n      <td>chl</td>\n      <td>0.06900</td>\n      <td>0.010744</td>\n      <td>0.008795</td>\n      <td>0.006032</td>\n      <td>0.003241</td>\n      <td>0.001549</td>\n      <td>0.000112</td>\n      <td>None</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>1265</td>\n      <td>45.3139</td>\n      <td>12.5083</td>\n      <td>2003/3/18 11:23</td>\n      <td>aaot_2003</td>\n      <td>S2003077110425.L2_MLAC.R0000020314_45N_45N_12E...</td>\n      <td>0</td>\n      <td>25</td>\n      <td>-507</td>\n      <td>46.33</td>\n      <td>...</td>\n      <td>1.974525</td>\n      <td>chl_a</td>\n      <td>2.09430</td>\n      <td>0.004212</td>\n      <td>0.004806</td>\n      <td>0.006625</td>\n      <td>0.006604</td>\n      <td>0.006209</td>\n      <td>0.000984</td>\n      <td>None</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>1268</td>\n      <td>45.3139</td>\n      <td>12.5083</td>\n      <td>2003/5/13 10:15</td>\n      <td>aaot_2003</td>\n      <td>S2003133112858.L2_MLAC.R0000020314_45N_45N_12E...</td>\n      <td>0</td>\n      <td>25</td>\n      <td>5341</td>\n      <td>28.09</td>\n      <td>...</td>\n      <td>1.779388</td>\n      <td>chl_a</td>\n      <td>0.96620</td>\n      <td>0.004451</td>\n      <td>0.004953</td>\n      <td>0.005663</td>\n      <td>0.005642</td>\n      <td>0.005284</td>\n      <td>0.000921</td>\n      <td>None</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>1276</td>\n      <td>45.3139</td>\n      <td>12.5083</td>\n      <td>2003/6/20 11:59</td>\n      <td>aaot_2003</td>\n      <td>S2003171110723.L2_MLAC.R0000020314_45N_45N_12E...</td>\n      <td>0</td>\n      <td>25</td>\n      <td>-2101</td>\n      <td>22.03</td>\n      <td>...</td>\n      <td>1.121444</td>\n      <td>chl_a</td>\n      <td>0.71310</td>\n      <td>0.003378</td>\n      <td>0.003701</td>\n      <td>0.004466</td>\n      <td>0.004142</td>\n      <td>0.003531</td>\n      <td>0.000316</td>\n      <td>None</td>\n    </tr>\n  </tbody>\n</table>\n<p>5 rows × 23 columns</p>\n</div>"
     },
     "metadata": {},
     "output_type": "execute_result",
     "execution_count": 3
    }
   ],
   "source": [
    "dt.head()\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "outputs": [
    {
     "name": "stdout",
     "text": [
      "['seawifs_rrs412', 'seawifs_rrs443', 'seawifs_rrs490', 'seawifs_rrs510', 'seawifs_rrs555', 'seawifs_rrs670']\n"
     ],
     "output_type": "stream"
    },
    {
     "data": {
      "text/plain": "          id  latitude  longitude         date_time        cruise  \\\n0     280136   29.0527   -87.3232   2010/5/13 21:02  2010_05_wbii   \n1     211974   17.6968   -66.0012  2003/10/28 18:12           a22   \n2       1265   45.3139    12.5083   2003/3/18 11:23     aaot_2003   \n3       1268   45.3139    12.5083   2003/5/13 10:15     aaot_2003   \n4       1276   45.3139    12.5083   2003/6/20 11:59     aaot_2003   \n...      ...       ...        ...               ...           ...   \n2273  209508   26.1518   -82.0972    2006/1/5 20:25       wfs0601   \n2274  209512   27.5394   -82.8044   2006/10/2 20:25       wfs0610   \n2275  209532   25.2882   -81.8809   2006/10/4 18:00       wfs0610   \n2276  209533   25.4736   -81.7759   2006/10/4 19:56       wfs0610   \n2277  209534   25.4670   -81.6173   2006/10/4 21:10       wfs0610   \n\n                                       seawifs_filename  seawifs_es_error  \\\n0     S2010133195617.L2_MLAC.R0000020308_2010_05_wbi...                 0   \n1     S2003301161018.L2_MLAC.R0000020313_17N_17N_66W...                 0   \n2     S2003077110425.L2_MLAC.R0000020314_45N_45N_12E...                 0   \n3     S2003133112858.L2_MLAC.R0000020314_45N_45N_12E...                 0   \n4     S2003171110723.L2_MLAC.R0000020314_45N_45N_12E...                 0   \n...                                                 ...               ...   \n2273  S2006005173614.L2_MLAC.R0000021569_26N_25N_82W...                 0   \n2274  S2006275185427.L2_MLAC.R0000021570_27N_27N_82W...                 0   \n2275  S2006277183908.L2_MLAC.R0000021570_25N_25N_81W...                 0   \n2276  S2006277183908.L2_MLAC.R0000021570_25N_25N_81W...                 0   \n2277  S2006277183908.L2_MLAC.R0000021570_25N_25N_81W...                 0   \n\n      seawifs_pixel_total  seawifs_tdiff  seawifs_solz  ...  rrs555/rrs412  \\\n0                      25          -2866         35.43  ...            NaN   \n1                      25          -6455         31.10  ...            NaN   \n2                      25           -507         46.33  ...            NaN   \n3                      25           5341         28.09  ...            NaN   \n4                      25          -2101         22.03  ...            NaN   \n...                   ...            ...           ...  ...            ...   \n2273                   25          -9458         48.83  ...            NaN   \n2274                   25          -4647         40.53  ...            NaN   \n2275                   25           3034         37.59  ...            NaN   \n2276                   25          -3929         37.79  ...            NaN   \n2277                   25          -8370         37.88  ...            NaN   \n\n      rrs555/rrs443  rrs555/rrs490  rrs555/rrs510 rrs555/rrs670  \\\n0               NaN            NaN            NaN           NaN   \n1               NaN            NaN            NaN           NaN   \n2               NaN            NaN            NaN           NaN   \n3               NaN            NaN            NaN           NaN   \n4               NaN            NaN            NaN           NaN   \n...             ...            ...            ...           ...   \n2273            NaN            NaN            NaN           NaN   \n2274            NaN            NaN            NaN           NaN   \n2275            NaN            NaN            NaN           NaN   \n2276            NaN            NaN            NaN           NaN   \n2277            NaN            NaN            NaN           NaN   \n\n      rrs670/rrs412  rrs670/rrs443  rrs670/rrs490  rrs670/rrs510  \\\n0               NaN            NaN            NaN            NaN   \n1               NaN            NaN            NaN            NaN   \n2               NaN            NaN            NaN            NaN   \n3               NaN            NaN            NaN            NaN   \n4               NaN            NaN            NaN            NaN   \n...             ...            ...            ...            ...   \n2273            NaN            NaN            NaN            NaN   \n2274            NaN            NaN            NaN            NaN   \n2275            NaN            NaN            NaN            NaN   \n2276            NaN            NaN            NaN            NaN   \n2277            NaN            NaN            NaN            NaN   \n\n      rrs670/rrs555  \n0               NaN  \n1               NaN  \n2               NaN  \n3               NaN  \n4               NaN  \n...             ...  \n2273            NaN  \n2274            NaN  \n2275            NaN  \n2276            NaN  \n2277            NaN  \n\n[2278 rows x 53 columns]",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>id</th>\n      <th>latitude</th>\n      <th>longitude</th>\n      <th>date_time</th>\n      <th>cruise</th>\n      <th>seawifs_filename</th>\n      <th>seawifs_es_error</th>\n      <th>seawifs_pixel_total</th>\n      <th>seawifs_tdiff</th>\n      <th>seawifs_solz</th>\n      <th>...</th>\n      <th>rrs555/rrs412</th>\n      <th>rrs555/rrs443</th>\n      <th>rrs555/rrs490</th>\n      <th>rrs555/rrs510</th>\n      <th>rrs555/rrs670</th>\n      <th>rrs670/rrs412</th>\n      <th>rrs670/rrs443</th>\n      <th>rrs670/rrs490</th>\n      <th>rrs670/rrs510</th>\n      <th>rrs670/rrs555</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>280136</td>\n      <td>29.0527</td>\n      <td>-87.3232</td>\n      <td>2010/5/13 21:02</td>\n      <td>2010_05_wbii</td>\n      <td>S2010133195617.L2_MLAC.R0000020308_2010_05_wbi...</td>\n      <td>0</td>\n      <td>25</td>\n      <td>-2866</td>\n      <td>35.43</td>\n      <td>...</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>211974</td>\n      <td>17.6968</td>\n      <td>-66.0012</td>\n      <td>2003/10/28 18:12</td>\n      <td>a22</td>\n      <td>S2003301161018.L2_MLAC.R0000020313_17N_17N_66W...</td>\n      <td>0</td>\n      <td>25</td>\n      <td>-6455</td>\n      <td>31.10</td>\n      <td>...</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>1265</td>\n      <td>45.3139</td>\n      <td>12.5083</td>\n      <td>2003/3/18 11:23</td>\n      <td>aaot_2003</td>\n      <td>S2003077110425.L2_MLAC.R0000020314_45N_45N_12E...</td>\n      <td>0</td>\n      <td>25</td>\n      <td>-507</td>\n      <td>46.33</td>\n      <td>...</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>1268</td>\n      <td>45.3139</td>\n      <td>12.5083</td>\n      <td>2003/5/13 10:15</td>\n      <td>aaot_2003</td>\n      <td>S2003133112858.L2_MLAC.R0000020314_45N_45N_12E...</td>\n      <td>0</td>\n      <td>25</td>\n      <td>5341</td>\n      <td>28.09</td>\n      <td>...</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>1276</td>\n      <td>45.3139</td>\n      <td>12.5083</td>\n      <td>2003/6/20 11:59</td>\n      <td>aaot_2003</td>\n      <td>S2003171110723.L2_MLAC.R0000020314_45N_45N_12E...</td>\n      <td>0</td>\n      <td>25</td>\n      <td>-2101</td>\n      <td>22.03</td>\n      <td>...</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>2273</th>\n      <td>209508</td>\n      <td>26.1518</td>\n      <td>-82.0972</td>\n      <td>2006/1/5 20:25</td>\n      <td>wfs0601</td>\n      <td>S2006005173614.L2_MLAC.R0000021569_26N_25N_82W...</td>\n      <td>0</td>\n      <td>25</td>\n      <td>-9458</td>\n      <td>48.83</td>\n      <td>...</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>2274</th>\n      <td>209512</td>\n      <td>27.5394</td>\n      <td>-82.8044</td>\n      <td>2006/10/2 20:25</td>\n      <td>wfs0610</td>\n      <td>S2006275185427.L2_MLAC.R0000021570_27N_27N_82W...</td>\n      <td>0</td>\n      <td>25</td>\n      <td>-4647</td>\n      <td>40.53</td>\n      <td>...</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>2275</th>\n      <td>209532</td>\n      <td>25.2882</td>\n      <td>-81.8809</td>\n      <td>2006/10/4 18:00</td>\n      <td>wfs0610</td>\n      <td>S2006277183908.L2_MLAC.R0000021570_25N_25N_81W...</td>\n      <td>0</td>\n      <td>25</td>\n      <td>3034</td>\n      <td>37.59</td>\n      <td>...</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>2276</th>\n      <td>209533</td>\n      <td>25.4736</td>\n      <td>-81.7759</td>\n      <td>2006/10/4 19:56</td>\n      <td>wfs0610</td>\n      <td>S2006277183908.L2_MLAC.R0000021570_25N_25N_81W...</td>\n      <td>0</td>\n      <td>25</td>\n      <td>-3929</td>\n      <td>37.79</td>\n      <td>...</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>2277</th>\n      <td>209534</td>\n      <td>25.4670</td>\n      <td>-81.6173</td>\n      <td>2006/10/4 21:10</td>\n      <td>wfs0610</td>\n      <td>S2006277183908.L2_MLAC.R0000021570_25N_25N_81W...</td>\n      <td>0</td>\n      <td>25</td>\n      <td>-8370</td>\n      <td>37.88</td>\n      <td>...</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n  </tbody>\n</table>\n<p>2278 rows × 53 columns</p>\n</div>"
     },
     "metadata": {},
     "output_type": "execute_result",
     "execution_count": 4
    }
   ],
   "source": [
    "commonCols = ['seawifs_rrs412','seawifs_rrs443','seawifs_rrs490','seawifs_rrs510','seawifs_rrs555','seawifs_rrs670']\n",
    "\n",
    "cols412 = ['rrs412/rrs443','rrs412/rrs490','rrs412/rrs510','rrs412/rrs555','rrs412/rrs670']\n",
    "cols443 = ['rrs443/rrs412','rrs443/rrs490','rrs443/rrs510','rrs443/rrs555','rrs443/rrs670']\n",
    "cols490 = ['rrs490/rrs412','rrs490/rrs443','rrs490/rrs510','rrs490/rrs555','rrs490/rrs670']\n",
    "cols510 = ['rrs510/rrs412','rrs510/rrs443','rrs510/rrs490','rrs510/rrs555','rrs510/rrs670']\n",
    "cols555 = ['rrs555/rrs412','rrs555/rrs443','rrs555/rrs490','rrs555/rrs510','rrs555/rrs670']\n",
    "cols670 = ['rrs670/rrs412','rrs670/rrs443','rrs670/rrs490','rrs670/rrs510','rrs670/rrs555']\n",
    "\n",
    "labelCol = ['seawifs_chlor_a','insitu_chlor_a']\n",
    "\n",
    "cols412.extend(cols443)\n",
    "cols412.extend(cols490)\n",
    "cols412.extend(cols510)\n",
    "cols412.extend(cols555)\n",
    "cols412.extend(cols670)\n",
    "\n",
    "\n",
    "\n",
    "col_name = dt.columns.tolist()\n",
    "\n",
    "col_name.extend(cols412)\n",
    "\n",
    "print(commonCols)\n",
    "dt.reindex(columns=col_name)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 412 波段比"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "outputs": [],
   "source": [
    "dt['rrs412/rrs443'] = dt['seawifs_rrs412']/dt['seawifs_rrs443']\n",
    "dt['rrs412/rrs490'] = dt['seawifs_rrs412']/dt['seawifs_rrs490']\n",
    "dt['rrs412/rrs510'] = dt['seawifs_rrs412']/dt['seawifs_rrs510']\n",
    "dt['rrs412/rrs555'] = dt['seawifs_rrs412']/dt['seawifs_rrs555']\n",
    "dt['rrs412/rrs670'] = dt['seawifs_rrs412']/dt['seawifs_rrs670']\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 443 波段比"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "outputs": [],
   "source": [
    "dt['rrs443/rrs412'] = dt['seawifs_rrs443']/dt['seawifs_rrs412']\n",
    "dt['rrs443/rrs490'] = dt['seawifs_rrs443']/dt['seawifs_rrs490']\n",
    "dt['rrs443/rrs510'] = dt['seawifs_rrs443']/dt['seawifs_rrs510']\n",
    "dt['rrs443/rrs555'] = dt['seawifs_rrs443']/dt['seawifs_rrs555']\n",
    "dt['rrs443/rrs670'] = dt['seawifs_rrs443']/dt['seawifs_rrs670']\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 490 波段比"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "outputs": [],
   "source": [
    "dt['rrs490/rrs412'] = dt['seawifs_rrs490']/dt['seawifs_rrs412']\n",
    "dt['rrs490/rrs443'] = dt['seawifs_rrs490']/dt['seawifs_rrs443']\n",
    "dt['rrs490/rrs510'] = dt['seawifs_rrs490']/dt['seawifs_rrs510']\n",
    "dt['rrs490/rrs555'] = dt['seawifs_rrs490']/dt['seawifs_rrs555']\n",
    "dt['rrs490/rrs670'] = dt['seawifs_rrs490']/dt['seawifs_rrs670']\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 510 波段比"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "outputs": [],
   "source": [
    "dt['rrs510/rrs412'] = dt['seawifs_rrs510']/dt['seawifs_rrs412']\n",
    "dt['rrs510/rrs443'] = dt['seawifs_rrs510']/dt['seawifs_rrs443']\n",
    "dt['rrs510/rrs490'] = dt['seawifs_rrs510']/dt['seawifs_rrs490']\n",
    "dt['rrs510/rrs555'] = dt['seawifs_rrs510']/dt['seawifs_rrs555']\n",
    "dt['rrs510/rrs670'] = dt['seawifs_rrs510']/dt['seawifs_rrs670']"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 555 波段比"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "outputs": [],
   "source": [
    "dt['rrs555/rrs412'] = dt['seawifs_rrs555']/dt['seawifs_rrs412']\n",
    "dt['rrs555/rrs443'] = dt['seawifs_rrs555']/dt['seawifs_rrs443']\n",
    "dt['rrs555/rrs490'] = dt['seawifs_rrs555']/dt['seawifs_rrs490']\n",
    "dt['rrs555/rrs510'] = dt['seawifs_rrs555']/dt['seawifs_rrs510']\n",
    "dt['rrs555/rrs670'] = dt['seawifs_rrs555']/dt['seawifs_rrs670']"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 670 波段比"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "outputs": [],
   "source": [
    "dt['rrs670/rrs412'] = dt['seawifs_rrs670']/dt['seawifs_rrs412']\n",
    "dt['rrs670/rrs443'] = dt['seawifs_rrs670']/dt['seawifs_rrs443']\n",
    "dt['rrs670/rrs490'] = dt['seawifs_rrs670']/dt['seawifs_rrs490']\n",
    "dt['rrs670/rrs510'] = dt['seawifs_rrs670']/dt['seawifs_rrs510']\n",
    "dt['rrs670/rrs555'] = dt['seawifs_rrs670']/dt['seawifs_rrs555']\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "outputs": [],
   "source": [
    "commonCols.extend(cols412)\n",
    "commonCols.extend(labelCol)\n",
    "\n",
    "trainDs = dt[commonCols]\n",
    "\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "outputs": [
    {
     "data": {
      "text/plain": "<matplotlib.collections.PathCollection at 0x2963020fb48>"
     },
     "metadata": {},
     "output_type": "execute_result",
     "execution_count": 12
    },
    {
     "data": {
      "text/plain": "<Figure size 432x288 with 1 Axes>",
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAD8CAYAAAB+UHOxAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAASaUlEQVR4nO3df4xdZZ3H8feX6QDTqjtFBxamsNRs065KtDBRlI1RUPmhgQYxYlztGjb9R1dAUy27ySqbTcBgRE0MSQNq3SUsbmkK4kaWFIzZTeju1CIFClsWFTqtdAwM/mCUafvdP+6Zdjq9M9OZe+/c6TzvVzK59zxzfjxzcuZ87nnOc54bmYkkqTwntLsCkqT2MAAkqVAGgCQVygCQpEIZAJJUKANAkgo1ZQBExLcjYl9EPD6m7JSIeDAidlWvi6vyiIhvRsQzEfFYRJzbyspLkmbuWK4AvgtcMq5sHbAlM5cBW6ppgEuBZdXPGuC25lRTktRsUwZAZv4EeHFc8RXAhur9BmDVmPLvZc0jQHdEnN6sykqSmmfBDJc7LTP3AmTm3og4tSrvBZ4fM9/uqmzv+BVExBpqVwksWrTovBUrVsywKpJUpm3btv06M3tmuvxMA2AiUaes7lgTmbkeWA/Q19eX/f39Ta6KJM1vEfHLRpafaS+gF0abdqrXfVX5buDMMfMtAfbMvHqSpFaZaQDcB6yu3q8G7h1T/smqN9D5wMujTUWSpLllyiagiLgLeA/whojYDXwJuBn4fkRcAzwHfKSa/d+By4BngFeAT7WgzpKkJpgyADLzYxP86qI68ybw6UYrJUlqPZ8ElqRCGQCSVCgDQJIKZQBIUqEMAEkqlAEgSYUyACSpUAaAJBXKAJCkQhkAklQoA0CSCmUASFKhDABJKpQBIEmFMg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DR6ucyam3fW4Bd1esp7a7rLO+X9wD3V+/fCPw38Azwb8BJ7a7fLO2DtwH91bGxGVhc6nEB3Ag8BTwO/DNwUknHBXAXtfsfI9Q+4V8z0bFArQnoW9W5dAe13lOTrt+hICSpUO1uApIktYkBIEmFMgAkqVAGgCQVygCQpEIZAJJUKANAkgr1/3LLz60ke9iLAAAAAElFTkSuQmCC\n"
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "trainDs.head(10)\n",
    "\n",
    "import matplotlib.pyplot as plt\n",
    "showDs = trainDs[trainDs['seawifs_chlor_a'] < 10]\n",
    "plt.axis([0, 100, 0, 100])\n",
    "plt.scatter(showDs.seawifs_chlor_a,showDs.insitu_chlor_a)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "outputs": [],
   "source": [
    "trainDs.to_csv(r'E:\\02Projects\\papers\\chl_model\\data\\seawifs\\train_dataset1.csv')"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "\n"
   ],
   "metadata": {
    "collapsed": false
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  },
  "pycharm": {
   "stem_cell": {
    "cell_type": "raw",
    "source": [],
    "metadata": {
     "collapsed": false
    }
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}